<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>webdoc</title>
    <link rel="stylesheet" type="text/css" href="../static/css/main.css">
</head>
<body>
<div class="nav">
    <div class="logo">
        
            webdoc
        
    </div>
<ul><li><a href="../index.html">0.Async</a></li><li><a href="../html/0.editor.html">0.editor</a></li><li><a href="../html/0.module.html">0.module</a></li><li><a href="../html/1.ES2015.html">1.ES2015</a></li><li><a href="../html/2.Promise.html">2.Promise</a></li><li><a href="../html/3.Node.html">3.Node</a></li><li><a href="../html/4.NodeInstall.html">4.NodeInstall</a></li><li><a href="../html/5.REPL.html">5.REPL</a></li><li><a href="../html/6.NodeCore.html">6.NodeCore</a></li><li><a href="../html/7.module&NPM.html">7.module&NPM</a></li><li><a href="../html/8.Encoding.html">8.Encoding</a></li><li><a href="../html/9.Buffer.html">9.Buffer</a></li><li><a href="../html/10.fs.html">10.fs</a></li><li><a href="../html/11.Stream-1.html">11.Stream-1</a></li><li><a href="../html/11.Stream-2.html">11.Stream-2</a></li><li><a href="../html/11.Stream-3.html">11.Stream-3</a></li><li><a href="../html/11.Stream-4.html">11.Stream-4</a></li><li><a href="../html/12-Network-2.html">12-Network-2</a></li><li><a href="../html/12.NetWork-3.html">12.NetWork-3</a></li><li><a href="../html/12.Network-1.html">12.Network-1</a></li><li><a href="../html/13.tcp.html">13.tcp</a></li><li><a href="../html/14.http-1.html">14.http-1</a></li><li><a href="../html/14.http-2.html">14.http-2</a></li><li><a href="../html/15.compress.html">15.compress</a></li><li><a href="../html/16.crypto.html">16.crypto</a></li><li><a href="../html/17.process.html">17.process</a></li><li><a href="../html/18.yargs.html">18.yargs</a></li><li><a href="../html/19.cache.html">19.cache</a></li><li><a href="../html/20.action.html">20.action</a></li><li><a href="../html/21.https.html">21.https</a></li><li><a href="../html/22.cookie.html">22.cookie</a></li><li><a href="../html/23.session.html">23.session</a></li><li><a href="../html/24.express-1.html">24.express-1</a></li><li><a href="../html/24.express-2.html">24.express-2</a></li><li><a href="../html/24.express-3.html">24.express-3</a></li><li><a href="../html/24.express-4.html">24.express-4</a></li><li><a href="../html/25.koa-1.html">25.koa-1</a></li><li><a href="../html/26.webpack-1-basic.html">26.webpack-1-basic</a></li><li><a href="../html/26.webpack-2-optimize.html">26.webpack-2-optimize</a></li><li><a href="../html/26.webpack-3.tapable.html">26.webpack-3.tapable</a></li><li><a href="../html/26.webpack-4-AST.html">26.webpack-4-AST</a></li><li><a href="../html/26.webpack-5-source.html">26.webpack-5-source</a></li><li><a href="../html/26.webpack-6-loader.html">26.webpack-6-loader</a></li><li><a href="../html/26.webpack-7-plugin.html">26.webpack-7-plugin</a></li><li><a href="../html/26.webpack-8-hand.html">26.webpack-8-hand</a></li><li><a href="../html/27.react-1.html">27.react-1</a></li><li><a href="../html/27.react-2.html">27.react-2</a></li><li><a href="../html/27.react-3.html">27.react-3</a></li><li><a href="../html/27.react-4-immutable.html">27.react-4-immutable</a></li><li><a href="../html/27.react-5-react-dom-diff.html">27.react-5-react-dom-diff</a></li><li><a href="../html/27.react-6.html">27.react-6</a></li><li><a href="../html/28.react-mobx.html">28.react-mobx</a></li><li><a href="../html/28.redux-0.html">28.redux-0</a></li><li><a href="../html/28.redux-1.html">28.redux-1</a></li><li><a href="../html/28.redux-2-中间件.html">28.redux-2-中间件</a></li><li><a href="../html/28.redux-3-saga.html">28.redux-3-saga</a></li><li><a href="../html/28.redux-jwt-back.html">28.redux-jwt-back</a></li><li><a href="../html/28.redux-jwt-front.html">28.redux-jwt-front</a></li><li><a href="../html/29.mongodb-1.html">29.mongodb-1</a></li><li><a href="../html/29.mongodb-2.html">29.mongodb-2</a></li><li><a href="../html/29.mongodb-3.html">29.mongodb-3</a></li><li><a href="../html/29.mongodb-4.html">29.mongodb-4</a></li><li><a href="../html/29.mongodb-5.html">29.mongodb-5</a></li><li><a href="../html/29.mongodb-6.html">29.mongodb-6</a></li><li><a href="../html/30.cms-1-mysql.html">30.cms-1-mysql</a></li><li><a href="../html/30.cms-2-mysql.html">30.cms-2-mysql</a></li><li><a href="../html/30.cms-3-mysql.html">30.cms-3-mysql</a></li><li><a href="../html/30.cms-4-egg.html">30.cms-4-egg</a></li><li><a href="../html/30.cms-5-api.html">30.cms-5-api</a></li><li><a href="../html/30.cms-6-roadhog.html">30.cms-6-roadhog</a></li><li><a href="../html/30.cms-7-umi.html">30.cms-7-umi</a></li><li><a href="../html/30.cms-8-dva.html">30.cms-8-dva</a></li><li><a href="../html/30.cms-9-dva.html">30.cms-9-dva</a></li><li><a href="../html/30.cms-10-dva.html">30.cms-10-dva</a></li><li><a href="../html/30.cms-11-front.html">30.cms-11-front</a></li><li><a href="../html/31.cms-12-api.html">31.cms-12-api</a></li><li><a href="../html/31.cms-13-front.html">31.cms-13-front</a></li><li><a href="../html/31.cms-14-deploy.html">31.cms-14-deploy</a></li><li><a href="../html/32.ant.html">32.ant</a></li><li><a href="../html/33.redis.html">33.redis</a></li><li><a href="../html/34.unittest.html">34.unittest</a></li><li><a href="../html/35.jwt.html">35.jwt</a></li><li><a href="../html/36.websocket-1.html">36.websocket-1</a></li><li><a href="../html/36.websocket-2.html">36.websocket-2</a></li><li><a href="../html/38.chat-api-1.html">38.chat-api-1</a></li><li><a href="../html/38.chat-api-2.html">38.chat-api-2</a></li><li><a href="../html/38.chat-3.html">38.chat-3</a></li><li><a href="../html/38.chat-api-3.html">38.chat-api-3</a></li><li><a href="../html/38.chat.html">38.chat</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/39.crawl-0.html">39.crawl-0</a></li><li><a href="../html/39.crawl-1.html">39.crawl-1</a></li><li><a href="../html/39.crawl-2.html">39.crawl-2</a></li><li class="active"><a href="../html/40.deploy.html">40.deploy</a></li><li><a href="../html/41.safe.html">41.safe</a></li><li><a href="../html/42.test.html">42.test</a></li><li><a href="../html/43.nginx.html">43.nginx</a></li><li><a href="../html/44.enzyme.html">44.enzyme</a></li><li><a href="../html/45.docker.html">45.docker</a></li><li><a href="../html/46.elastic.html">46.elastic</a></li><li><a href="../html/47.oauth.html">47.oauth</a></li><li><a href="../html/48.wxpay.html">48.wxpay</a></li><li><a href="../html/49.nunjucks.html">49.nunjucks</a></li><li><a href="../html/50.ketang.html">50.ketang</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/51.typescript.html">51.typescript</a></li><li><a href="../html/52.UML.html">52.UML</a></li><li><a href="../html/53.design.html">53.design</a></li><li><a href="../html/index.html">index</a></li></ul></div>


<div class="warpper">

    <div class="page-toc">
        <ul><li><a href="#t01.2 购买域名">1.2 购买域名</a></li><li><a href="#t11.3 云主机">1.3 云主机</a></li><li><a href="#t21.4 购买阿里云">1.4 购买阿里云</a></li><li><a href="#t31.5 备案">1.5 备案</a></li><li><a href="#t42 服务器">2 服务器</a><ul><li><a href="#t52.1  连接服务器">2.1  连接服务器</a></li><li><a href="#t62.2  创建用户">2.2  创建用户</a></li><li><a href="#t72.3 赋予权限">2.3 赋予权限</a></li><li><a href="#t82.4 添加sudo权限">2.4 添加sudo权限</a></li><li><a href="#t92.5 SSH无密码登录">2.5 SSH无密码登录</a><ul><li><a href="#t102.5.1  本地生成公钥和私钥">2.5.1  本地生成公钥和私钥</a></li><li><a href="#t112.5.2 开启ssh代理">2.5.2 开启ssh代理</a></li><li><a href="#t122.5.3 服务器配置">2.5.3 服务器配置</a></li><li><a href="#t132.5.4 把本地的公钥上传到服务器授权文件中">2.5.4 把本地的公钥上传到服务器授权文件中</a></li></ul></li><li><a href="#t142.6 增加安全等级">2.6 增加安全等级</a></li><li><a href="#t152.7 配置防火墙">2.7 配置防火墙</a></li><li><a href="#t162.8 安装软件">2.8 安装软件</a></li><li><a href="#t172.9 安装node">2.9 安装node</a></li><li><a href="#t182.10 编写node程序">2.10 编写node程序</a></li><li><a href="#t192.11 启动程序">2.11 启动程序</a></li><li><a href="#t202.12 nginx">2.12 nginx</a><ul><li><a href="#t212.12.1 安装">2.12.1 安装</a></li><li><a href="#t222.12.2 nginx命令">2.12.2 nginx命令</a></li><li><a href="#t232.12.3 nginx配置">2.12.3 nginx配置</a></li><li><a href="#t242.12.4 重启nginx">2.12.4 重启nginx</a></li></ul></li><li><a href="#t252.13 mysql">2.13 mysql</a></li><li><a href="#t262.14 克隆项目">2.14 克隆项目</a></li></ul></li></ul>
    </div>
    
    <div class="content markdown-body">
        <p>&#xFEFF;##  1. &#x670D;&#x52A1;&#x5668;&#x90E8;&#x7F72;&#x6B65;&#x9AA4;</p>
<ol>
<li>&#x8D2D;&#x4E70;&#x81EA;&#x5DF1;&#x7684;&#x57DF;&#x540D;</li>
<li>&#x57DF;&#x540D;&#x5907;&#x6848;</li>
<li>&#x8D2D;&#x4E70;&#x670D;&#x52A1;&#x5668;</li>
<li>&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;&#x5E94;&#x7528;&#x73AF;&#x5883;</li>
<li>&#x5B89;&#x88C5;&#x914D;&#x7F6E;&#x670D;&#x52A1;&#x5668;</li>
<li>&#x9879;&#x76EE;&#x8FDC;&#x7A0B;&#x90E8;&#x7F72;&#x548C;&#x53D1;&#x5E03;&#x4E0E;&#x66F4;&#x65B0;</li>
</ol>
<h3 id="t01.2 &#x8D2D;&#x4E70;&#x57DF;&#x540D;">1.2 &#x8D2D;&#x4E70;&#x57DF;&#x540D; <a href="#t01.2 &#x8D2D;&#x4E70;&#x57DF;&#x540D;"> # </a></h3>
<ul>
<li><a href="https://dnspod.cloud.tencent.com/">&#x817E;&#x8BAF;&#x4E91;</a></li>
<li><a href="https://wanwang.aliyun.com/">&#x963F;&#x91CC;&#x4E91;</a></li>
<li><a href="https://cloud.baidu.com/product/bcd.html">&#x767E;&#x5EA6;&#x4E91;</a></li>
<li><a href="https://www.22.cn/">&#x7231;&#x540D;&#x7F51;</a></li>
<li><a href="https://sg.godaddy.com/">godaddy</a></li>
</ul>
<h3 id="t11.3 &#x4E91;&#x4E3B;&#x673A;">1.3 &#x4E91;&#x4E3B;&#x673A; <a href="#t11.3 &#x4E91;&#x4E3B;&#x673A;"> # </a></h3>
<ul>
<li><a href="https://www.aliyun.com/">&#x963F;&#x91CC;&#x4E91; ECS</a></li>
<li><a href="https://aws.amazon.com/cn/">&#x4E9A;&#x9A6C;&#x900A; AWS</a></li>
<li><a href="https://cloud.baidu.com/">&#x767E;&#x5EA6;&#x4E91;</a></li>
</ul>
<h3 id="t21.4 &#x8D2D;&#x4E70;&#x963F;&#x91CC;&#x4E91;">1.4 &#x8D2D;&#x4E70;&#x963F;&#x91CC;&#x4E91; <a href="#t21.4 &#x8D2D;&#x4E70;&#x963F;&#x91CC;&#x4E91;"> # </a></h3>
<ul>
<li><a href="https://ecs-buy.aliyun.com/wizard/#/postpay/cn-beijing">&#x9009;&#x62E9;&#x914D;&#x7F6E;</a></li>
<li>&#x955C;&#x50CF; Ubuntu 16.04 64&#x4F4D;</li>
</ul>
<h3 id="t31.5 &#x5907;&#x6848;">1.5 &#x5907;&#x6848; <a href="#t31.5 &#x5907;&#x6848;"> # </a></h3>
<ul>
<li><a href="https://beian.aliyun.com">&#x963F;&#x91CC;&#x4E91;&#x5907;&#x6848;</a></li>
<li><a href="https://bsn.console.aliyun.com/#/bsnManagement">&#x5907;&#x6848;&#x670D;&#x52A1;&#x53F7;&#x7BA1;&#x7406;</a></li>
</ul>
<h2 id="t42 &#x670D;&#x52A1;&#x5668;">2 &#x670D;&#x52A1;&#x5668; <a href="#t42 &#x670D;&#x52A1;&#x5668;"> # </a></h2>
<h3 id="t52.1  &#x8FDE;&#x63A5;&#x670D;&#x52A1;&#x5668;">2.1  &#x8FDE;&#x63A5;&#x670D;&#x52A1;&#x5668; <a href="#t52.1  &#x8FDE;&#x63A5;&#x670D;&#x52A1;&#x5668;"> # </a></h3>
<pre><code class="lang-js">ssh root@<span class="hljs-number">39.96</span><span class="hljs-number">.114</span><span class="hljs-number">.57</span>
</code></pre>
<h3 id="t62.2  &#x521B;&#x5EFA;&#x7528;&#x6237;">2.2  &#x521B;&#x5EFA;&#x7528;&#x6237; <a href="#t62.2  &#x521B;&#x5EFA;&#x7528;&#x6237;"> # </a></h3>
<pre><code class="lang-js">adduser juejin
</code></pre>
<h3 id="t72.3 &#x8D4B;&#x4E88;&#x6743;&#x9650;">2.3 &#x8D4B;&#x4E88;&#x6743;&#x9650; <a href="#t72.3 &#x8D4B;&#x4E88;&#x6743;&#x9650;"> # </a></h3>
<p>gpasswd&#x547D;&#x4EE4;&#x662F;Linux&#x4E0B;&#x5DE5;&#x4F5C;&#x7EC4;&#x6587;&#x4EF6;/etc/group&#x548C;/etc/gshadow&#x7BA1;&#x7406;&#x5DE5;&#x5177;&#x3002;</p>
<ul>
<li>-a&#xFF1A;&#x6DFB;&#x52A0;&#x7528;&#x6237;&#x5230;&#x7EC4;</li>
<li>-d&#xFF1A;&#x4ECE;&#x7EC4;&#x5220;&#x9664;&#x7528;&#x6237;<pre><code class="lang-js">gpasswd -a juejin sudo
</code></pre>
</li>
</ul>
<h3 id="t82.4 &#x6DFB;&#x52A0;sudo&#x6743;&#x9650;">2.4 &#x6DFB;&#x52A0;sudo&#x6743;&#x9650; <a href="#t82.4 &#x6DFB;&#x52A0;sudo&#x6743;&#x9650;"> # </a></h3>
<p>Linux&#x7528;&#x6237;&#x914D;&#x7F6E;sudo&#x6743;&#x9650;(visudo),&#x5982;&#x679C;&#x4F60;&#x7528;visudo&#x6765;&#x7F16;&#x8F91;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x4F1A;&#x5E2E;&#x4F60;&#x81EA;&#x52A8;&#x505A;&#x5F88;&#x591A;&#x4E8B;&#x60C5;&#xFF0C;&#x6BD4;&#x5982;&#x8BF4;&#x8BED;&#x6CD5;&#x68C0;&#x67E5;&#xFF0C;&#x52A0;&#x9501;&#x9632;&#x6B62;&#x522B;&#x4EBA;&#x540C;&#x65F6;&#x4FEE;&#x6539;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x7B49;&#x7B49;</p>
<pre><code class="lang-js">sudo visudo
</code></pre>
<blockquote>
<p>visudo&#x5176;&#x5B9E;&#x662F;&#x6253;&#x5F00;/etc/sudoers</p>
</blockquote>
<pre><code class="lang-js"># User privilege specification
juejin  ALL=(ALL:ALL) ALL
</code></pre>
<ul>
<li>1 &quot;From ALL hosts juejin&quot; &#x4ECE;&#x4EFB;&#x4F55;&#x673A;&#x5668;&#x767B;&#x5F55;&#xFF0C;&#x90FD;&#x53EF;&#x4EE5;&#x5E94;&#x7528;&#x63A5;&#x4E0B;&#x6765;&#x7684;&#x89C4;&#x5219;</li>
<li>2 &quot;Run As ALL User&quot;,juejin&#x53EF;&#x4EE5;&#x4EE5;&#x4EFB;&#x4F55;&#x7528;&#x6237;&#x7684;&#x8EAB;&#x4EFD;&#x8FD0;&#x884C;&#x4E00;&#x4E9B;&#x547D;&#x4EE4;</li>
<li>3 &quot;Run As All Groups&quot; juejin&#x53EF;&#x4EE5;&#x4EE5;&#x4EFB;&#x4F55;&#x7528;&#x6237;&#x7EC4;&#x7684;&#x8EAB;&#x4EFD;&#x8FD0;&#x884C;&#x4E00;&#x4E9B;&#x547D;&#x4EE4;</li>
<li>4 &#x524D;&#x9762;&#x7684;&#x89C4;&#x5B9A;&#x9002;&#x7528;&#x4E8E;&#x4EFB;&#x4F55;&#x547D;&#x4EE4;</li>
</ul>
<blockquote>
<p>juejin&#x8FD9;&#x4E2A;&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x4ECE;&#x4EFB;&#x4F55;&#x673A;&#x5668;&#x767B;&#x5F55;&#xFF0C;&#x4EE5;&#x4EFB;&#x4F55;&#x7528;&#x6237;&#x548C;&#x7528;&#x6237;&#x7EC4;&#x7684;&#x8EAB;&#x4EFD;&#x8FD0;&#x884C;&#x4EFB;&#x4F55;&#x547D;&#x4EE4;&#x3002;
&#x4FDD;&#x5B58;&#x5E76;&#x9000;&#x51FA;</p>
<pre><code class="lang-js">Ctrl+X
shift + y
</code></pre>
</blockquote>
<h3 id="t92.5 SSH&#x65E0;&#x5BC6;&#x7801;&#x767B;&#x5F55;">2.5 SSH&#x65E0;&#x5BC6;&#x7801;&#x767B;&#x5F55; <a href="#t92.5 SSH&#x65E0;&#x5BC6;&#x7801;&#x767B;&#x5F55;"> # </a></h3>
<p>ssh &#x516C;&#x94A5;&#x8BA4;&#x8BC1;&#x662F;ssh&#x8BA4;&#x8BC1;&#x7684;&#x65B9;&#x5F0F;&#x4E4B;&#x4E00;&#x3002;&#x901A;&#x8FC7;&#x516C;&#x94A5;&#x8BA4;&#x8BC1;&#x53EF;&#x5B9E;&#x73B0;ssh&#x514D;&#x5BC6;&#x7801;&#x767B;&#x9646;&#xFF0C;git&#x7684;ssh&#x65B9;&#x5F0F;&#x4E5F;&#x662F;&#x901A;&#x8FC7;&#x516C;&#x94A5;&#x8FDB;&#x884C;&#x8BA4;&#x8BC1;&#x7684;&#x3002;</p>
<h4 id="t102.5.1  &#x672C;&#x5730;&#x751F;&#x6210;&#x516C;&#x94A5;&#x548C;&#x79C1;&#x94A5;">2.5.1  &#x672C;&#x5730;&#x751F;&#x6210;&#x516C;&#x94A5;&#x548C;&#x79C1;&#x94A5; <a href="#t102.5.1  &#x672C;&#x5730;&#x751F;&#x6210;&#x516C;&#x94A5;&#x548C;&#x79C1;&#x94A5;"> # </a></h4>
<pre><code class="lang-js">ssh-keygen --help
cd ~/.ssh
ssh-keygen -t rsa -b 4096
</code></pre>
<ul>
<li>-t &#x6307;&#x5B9A;&#x52A0;&#x5BC6;&#x65B9;&#x5F0F;</li>
<li>-b &#x5B57;&#x8282;&#x6570;</li>
</ul>
<h4 id="t112.5.2 &#x5F00;&#x542F;ssh&#x4EE3;&#x7406;">2.5.2 &#x5F00;&#x542F;ssh&#x4EE3;&#x7406; <a href="#t112.5.2 &#x5F00;&#x542F;ssh&#x4EE3;&#x7406;"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-built_in">eval</span> <span class="hljs-string">&quot;$(ssh-agent -s)&quot;</span>
ssh-add ~<span class="hljs-regexp">/.ssh/i</span>d_rsa
</code></pre>
<h4 id="t122.5.3 &#x670D;&#x52A1;&#x5668;&#x914D;&#x7F6E;">2.5.3 &#x670D;&#x52A1;&#x5668;&#x914D;&#x7F6E; <a href="#t122.5.3 &#x670D;&#x52A1;&#x5668;&#x914D;&#x7F6E;"> # </a></h4>
<pre><code class="lang-js"><span class="hljs-built_in">eval</span> <span class="hljs-string">&quot;$(ssh-agent -s)&quot;</span>
ssh-add ~<span class="hljs-regexp">/.ssh/i</span>d_rsa
ssh-keygen -t rsa -b <span class="hljs-number">4096</span>
</code></pre>
<h4 id="t132.5.4 &#x628A;&#x672C;&#x5730;&#x7684;&#x516C;&#x94A5;&#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x6388;&#x6743;&#x6587;&#x4EF6;&#x4E2D;">2.5.4 &#x628A;&#x672C;&#x5730;&#x7684;&#x516C;&#x94A5;&#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x6388;&#x6743;&#x6587;&#x4EF6;&#x4E2D; <a href="#t132.5.4 &#x628A;&#x672C;&#x5730;&#x7684;&#x516C;&#x94A5;&#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x6388;&#x6743;&#x6587;&#x4EF6;&#x4E2D;"> # </a></h4>
<pre><code class="lang-js">vi ~<span class="hljs-regexp">/.ssh/</span>authorized_keys
chmod <span class="hljs-number">600</span> ~<span class="hljs-regexp">/.ssh/</span>authorized_keys
sudo service ssh restart
</code></pre>
<h3 id="t142.6 &#x589E;&#x52A0;&#x5B89;&#x5168;&#x7B49;&#x7EA7;">2.6 &#x589E;&#x52A0;&#x5B89;&#x5168;&#x7B49;&#x7EA7; <a href="#t142.6 &#x589E;&#x52A0;&#x5B89;&#x5168;&#x7B49;&#x7EA7;"> # </a></h3>
<pre><code class="lang-js">sudo vi /etc/ssh/sshd_config
     vi /etc/ssh/sshd_config
</code></pre>
<pre><code class="lang-js">Port <span class="hljs-number">2222</span>
AllowUsers juejin

PermitRootLogin yes
PasswordAuthentication yes
</code></pre>
<pre><code class="lang-js">sudo service ssh restart
/etc/init.d/ssh restart
lsof -i:<span class="hljs-number">2222</span>
</code></pre>
<pre><code class="lang-js">ssh -p <span class="hljs-number">2222</span> juejin@<span class="hljs-number">39.96</span><span class="hljs-number">.114</span><span class="hljs-number">.57</span>
</code></pre>
<h3 id="t152.7 &#x914D;&#x7F6E;&#x9632;&#x706B;&#x5899;">2.7 &#x914D;&#x7F6E;&#x9632;&#x706B;&#x5899; <a href="#t152.7 &#x914D;&#x7F6E;&#x9632;&#x706B;&#x5899;"> # </a></h3>
<h3 id="t162.8 &#x5B89;&#x88C5;&#x8F6F;&#x4EF6;">2.8 &#x5B89;&#x88C5;&#x8F6F;&#x4EF6; <a href="#t162.8 &#x5B89;&#x88C5;&#x8F6F;&#x4EF6;"> # </a></h3>
<pre><code class="lang-js">sudo apt-get update
sudo apt-get install wget curl git
</code></pre>
<h3 id="t172.9 &#x5B89;&#x88C5;node">2.9 &#x5B89;&#x88C5;node <a href="#t172.9 &#x5B89;&#x88C5;node"> # </a></h3>
<ul>
<li><a href="https://github.com/creationix/nvm/blob/master/README.md">nvm</a><pre><code class="lang-js">wget -qO- https:<span class="hljs-comment">//raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash</span>
nvm install stable
node -v
npm i cnpm -g
npm i nrm -g
</code></pre>
</li>
</ul>
<h3 id="t182.10 &#x7F16;&#x5199;node&#x7A0B;&#x5E8F;">2.10 &#x7F16;&#x5199;node&#x7A0B;&#x5E8F; <a href="#t182.10 &#x7F16;&#x5199;node&#x7A0B;&#x5E8F;"> # </a></h3>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> http = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;http&apos;</span>);

<span class="hljs-keyword">const</span> hostname = <span class="hljs-string">&apos;39.96.114.57&apos;</span>;
<span class="hljs-keyword">const</span> port = <span class="hljs-number">3000</span>;

<span class="hljs-keyword">const</span> server = http.createServer(<span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.statusCode = <span class="hljs-number">200</span>;
  res.setHeader(<span class="hljs-string">&apos;Content-Type&apos;</span>, <span class="hljs-string">&apos;text/plain&apos;</span>);
  res.end(<span class="hljs-string">&apos;Hello World\n&apos;</span>);
});

server.listen(port, hostname, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Server running at http://<span class="hljs-subst">${hostname}</span>:<span class="hljs-subst">${port}</span>/`</span>);
});
</code></pre>
<h3 id="t192.11 &#x542F;&#x52A8;&#x7A0B;&#x5E8F;">2.11 &#x542F;&#x52A8;&#x7A0B;&#x5E8F; <a href="#t192.11 &#x542F;&#x52A8;&#x7A0B;&#x5E8F;"> # </a></h3>
<p>&#x5F3A;&#x5927;&#x7684;&#x8FDB;&#x7A0B;&#x7BA1;&#x7406;&#x5668;&#xFF0C;&#x8FDB;&#x7A0B;&#x5F02;&#x5E38;&#x9000;&#x51FA;&#x65F6;pm2&#x4F1A;&#x5C1D;&#x8BD5;&#x91CD;&#x542F;</p>
<pre><code class="lang-js">npm install pm2 -g
</code></pre>
<p>&#x7528;pm2&#x542F;&#x52A8;node
|&#x547D;&#x4EE4;|&#x7528;&#x9014;|
|:----|:----|
|pm2 start app.js --name &quot;crawl&quot;|&#x542F;&#x52A8;&#x5E94;&#x7528;|
|pm2 list|&#x67E5;&#x770B;&#x6240;&#x6709;&#x5E94;&#x7528;|
|pm2 restart crawl|&#x91CD;&#x542F;&#x5E94;&#x7528;|
|pm2 stop crawl|&#x505C;&#x6B62;&#x5E94;&#x7528;|
|pm2 delete crawl|&#x5220;&#x9664;&#x5E94;&#x7528;|</p>
<pre><code class="lang-js">node app.js
pm2 start app.js --name <span class="hljs-string">&apos;juejin&apos;</span>
</code></pre>
<h3 id="t202.12 nginx">2.12 nginx <a href="#t202.12 nginx"> # </a></h3>
<p>Nginx&#x662F;&#x4E00;&#x4E2A;&#x9AD8;&#x6027;&#x80FD;&#x7684;HTTP&#x548C;&#x53CD;&#x5411;&#x4EE3;&#x7406;&#x670D;&#x52A1;&#x5668;</p>
<h4 id="t212.12.1 &#x5B89;&#x88C5;">2.12.1 &#x5B89;&#x88C5; <a href="#t212.12.1 &#x5B89;&#x88C5;"> # </a></h4>
<pre><code class="lang-js">apt-get install nginx
</code></pre>
<h4 id="t222.12.2 nginx&#x547D;&#x4EE4;">2.12.2 nginx&#x547D;&#x4EE4; <a href="#t222.12.2 nginx&#x547D;&#x4EE4;"> # </a></h4>
<table>
<thead>
<tr>
<th style="text-align:left">&#x540D;&#x79F0;</th>
<th style="text-align:left">&#x547D;&#x4EE4;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">&#x542F;&#x52A8;nginx</td>
<td style="text-align:left">nginx -c /etc/nginx/nginx.conf</td>
</tr>
<tr>
<td style="text-align:left">&#x5173;&#x95ED; nginx</td>
<td style="text-align:left">nginx -s stop</td>
</tr>
<tr>
<td style="text-align:left">&#x91CD;&#x8BFB;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</td>
<td style="text-align:left">nginx -s reload kill -HUP nginx</td>
</tr>
<tr>
<td style="text-align:left">&#x5E38;&#x7528;&#x547D;&#x4EE4;</td>
<td style="text-align:left">service nginx {start</td>
<td>stop</td>
<td>status</td>
<td>restart</td>
<td>reload</td>
<td>configtest</td>
<td>}</td>
</tr>
</tbody>
</table>
<h4 id="t232.12.3 nginx&#x914D;&#x7F6E;">2.12.3 nginx&#x914D;&#x7F6E; <a href="#t232.12.3 nginx&#x914D;&#x7F6E;"> # </a></h4>
<pre><code class="lang-js">cd /etc/nginx/sites-enabled
sudo vi juejin.conf
</code></pre>
<pre><code class="lang-js">upstream juejin{
    server <span class="hljs-number">39.96</span><span class="hljs-number">.114</span><span class="hljs-number">.57</span>:<span class="hljs-number">3000</span>;
}
server {
    listen <span class="hljs-number">80</span>;
    server_name <span class="hljs-number">39.96</span><span class="hljs-number">.114</span><span class="hljs-number">.57</span>;
    location / {
        proxy_pass http:<span class="hljs-comment">//juejin;</span>
    }
}
</code></pre>
<h4 id="t242.12.4 &#x91CD;&#x542F;nginx">2.12.4 &#x91CD;&#x542F;nginx <a href="#t242.12.4 &#x91CD;&#x542F;nginx"> # </a></h4>
<pre><code class="lang-js"> sudo nginx -s reload
</code></pre>
<h3 id="t252.13 mysql">2.13 mysql <a href="#t252.13 mysql"> # </a></h3>
<p>&#x5B89;&#x88C5;mysql</p>
<pre><code class="lang-js">sudo apt-get install mysql-server
apt install mysql-client
apt install libmysqlclient-dev
</code></pre>
<ul>
<li><a href="https://www.cnblogs.com/roadofstudy/p/7446690.html">root&#x7528;&#x6237;&#x91CD;&#x7F6E;&#x5BC6;&#x7801;&#x95EE;&#x9898;</a><h3 id="t262.14 &#x514B;&#x9686;&#x9879;&#x76EE;">2.14 &#x514B;&#x9686;&#x9879;&#x76EE; <a href="#t262.14 &#x514B;&#x9686;&#x9879;&#x76EE;"> # </a></h3>
</li>
</ul>

        <div class="copyright">Powered by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a>. Dependence <a href="https://nodejs.org">Node.js</a> run.</div>
    </div>
    
</div>

<script src="https://cdn.bootcss.com/jquery/3.0.0/jquery.js"></script>
<script>
$('.warpper .page-toc ul ul li a').on('click',function(){
  $('.warpper .page-toc ul ul li a').removeClass('my-active')
  $(this).addClass('my-active')
})
  // if (!$('.understand-me').length) {
  //   var bar = $(window).height() - $('.navbar ').height() - $('.page-toc').position().top;
  //   var count = bar / 26 / 2;
  //   var barHeight = $('.page-toc').outerHeight();
  //   $('.page-toc li').eq(0).children('a').addClass('red');
  //   var arr = [];
  //   $("h1,h2,h3,h4,h5,h6").each(function () {
  //     arr.push($(this).position().top);
  //   });
  //   var timer
  //   function dark() {
  //     clearTimeout(timer)
  //      timer = setTimeout(function () {
  //      var top = Math.abs($('.page-toc > ul').position().top);
  //      var cur = $('.content').scrollTop();
  //      for (var i = arr.length; i >= 0; i--) {
  //        if (arr[i] <= cur) {
  //          break;
  //        }
  //      }
  //      if (i === -1) {
  //        i = 0;
  //      }
  //      $('.page-toc li a').removeClass('red');
  //      $('.page-toc li').eq(i).children('a').addClass('red');
  //      let height = $('.page-toc li').eq(i).position().top-$('.page-toc').height(); // 如果当前的offset出去了 回到中间可好？
  //      $('.page-toc').scrollTop(height+$('.page-toc').height()/2);
  //    },200)
  //   }

  //   $('.content').on('scroll', dark);
  // }
</script>
<style>

    /* ::-webkit-scrollbar{width:14px;}
    ::-webkit-scrollbar-track{background-color:transparent;}
    ::-webkit-scrollbar-thumb{background-color:transparent;}
    ::-webkit-scrollbar-thumb:hover {background-color:transparent}
    ::-webkit-scrollbar-thumb:active {background-color:transparent} */

    .page-toc > ul .red {
        background: #f3f3f3;
        z-index: 1;
        border-left: 3px solid #009a61;
        -webkit-transition: all .2s ease;
        transition: all .2s ease;
        color: #000
    }





</style>
</body>
</html>
